\documentclass{article}

\usepackage[top=25mm,bottom=25mm,left=25mm,right=25mm]{geometry}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{subfig}
\usepackage{epstopdf}

\begin{document}

\title{ESP - Analog lab 1-3}
\author{Floris van Nee \& Simon Dirlik}

\maketitle

\section{} %1
The centre frequency is shifted down to make it better suitable for the ADC to process. The higher the frequency, the harder it is for the ADC to process, because a higher sampling rate is needed. This leads for example to a higher power dissipation. Also, for very high frequencies it is not possible to obtain a sampling rate as high as half the frequency. Because we are only interested in the frequency range defined by the center frequency and the bandwidth of the signal, it is possible to downconvert this signal into a signal at baseband, which loosens the requirements on the ADC.

\section{} %2
As local oscillator frequency 135 MHz can be chosen. Then:
\[\begin{split}
V_{out}		= &	V_{in}\cdot V_{LO} = \frac{1}{2} A_{in}A_{LO}sin[(\omega_{LO} - \omega_{in})t + (\phi_{LO} - \phi_{in})] +\\
			 &	\frac{1}{2} A_{in}A_{LO}sin[(\omega_{LO} + \omega_{in})t + (\phi_{LO} + \phi_{in})]\\
			= &	\frac{1}{2} A_{in}A_{LO}sin[(135\cdot10^6 \cdot 2\pi - 140\cdot10^6 \cdot 2\pi)t + (\phi_{LO} - \phi_{in})] +\\
			 &	\frac{1}{2} A_{in}A_{LO}sin[(135\cdot10^6 \cdot 2\pi + 140\cdot10^6 \cdot 2\pi)t + (\phi_{LO} + \phi_{in})]\\
\end{split}
\]
This gives two signals as result: one with a center frequency of 5 MHz and one with a center frequency of 275 MHz. Both have the same bandwidth of 10 MHz. The requirements on the ADC for the lower frequency signal are minimal because it is at baseband, having a lowest frequency of 0.

\section{} %3
Referring to the answer to the previous question, the high frequency component has a center frequency of 275 MHz and a bandwidth of 10 MHz.

\section{} %4
The 170 MHz signal is also downmixed by the local oscillator signal in the same way as our wanted signal. We can apply the same formula, resulting in a lower center frequency of $170-135=35$ MHz. Because the bandwidth is 10 MHz, the lowest frequency of the unwanted signal is $35-5=30$ MHz.

\section{} %5
The order of the filter should be such that the amplitude of the interference signal is smaller than 1 LSB. Because the ADC has a resolution of 6 bits, 1 LSB equals $\frac{1}{2}^6$ of the total amplitude. Both signals have the same amplitude, thus the signal at 30 MHz, the lowest frequency of the interfering signal, should have at least $20 \cdot log(\frac{1}{2}^6) = 36.1 dB$ attenuation.
\\
This attenuation should be achieved between the corner frequency of the filter and 30 MHz. The corner frequency can be chosen to be 10 MHz, as before that the signal should not be attenuated too much. This leaves the frequency range between 10 MHz and 30 MHz for the filter to achieve 36.1 dB, a factor three. A $n$th order filter goes down by $6\cdot n$ dB per octave. This is roughly equal to $9.5 \cdot n$ dB per increase in factor 3 of the frequency.
\\
Therefore, to achieve 36.1 dB, a $\left\lceil \frac{36.1}{9.5} \right\rceil = 4$th order filter is needed.

\section{}%6
We choose $R_1 = 1k\Omega$ and for the corner frequency $\omega = 10MHz$. Then we can calculate: $R_2 = 100\cdot R_1 = 100k\Omega$, $C_1 = C_2 = \frac {1} {\omega R_1} = \frac {1} {10\cdot10^6\cdot2\pi\cdot1\cdot10^3} = 15.9pF$ and $L = 2R_1^2C_1 = 2\cdot(1\cdot10^3)^2\cdot15.9\cdot10^{-12} = 31\mu H$.
This gives the response shown in figure \ref{fig:response_passive}.

\section{}%7
\begin{figure}[h]
	\begin{center}
		\includegraphics{img/filter_passive.png}
		\caption{The passive filter scheme in LTSpice}
		\label{fig:filter_passive}
	\end{center}
\end{figure}
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=0.9\textwidth]{img/response_passive.png}
		\caption{The response of the filter using the values calculated in exercise 6}
		\label{fig:response_passive}
	\end{center}
\end{figure}
\clearpage
\section{}%8
The state equations for the filter in figure \ref{fig:filter_passive} are:
\begin{equation}
	\begin{split}
		x	& =		\left[\begin{array}{ccc}V_{C_1}\\i_L\\V_{C_2}\end{array}\right]\\%state vector, state variables
	\end{split}
\end{equation}
For the first state variable $V_{C_1}$, we can derive the following equations:
\begin{equation}
	\begin{split}
		\dfrac {1} {sC_1} = \dfrac {V_{C_1}} {i_{C_1}}	& \Rightarrow sV_{C_1}\cdot C_1 = i_{C_1}\\
		i_{C_1}											& = i_{R_1} - i_L\\
		sV_{C_1}\cdot C_1								& = \dfrac {V_{in} - V_{C_1}} {R_1} - i_L\\
		sV_{C_1}										& = -\dfrac {V_{C_1}} {R_1C_1} - \dfrac {i_L} {C_1} + \dfrac {V_{in}} {R_1C_1}\\
	\end{split}
	\label{eq:svc1}
\end{equation}
We define $V_L=i_L\cdot R_x$, where $R_x$ is some arbitrary resistor, because the integrator output has to be a voltage. As a value for this resistor we choose $R_x=R_1$. This gives us the integrator in figure \ref{fig:gmint1}.
\begin{figure}[h]
	\begin{center}
		\includegraphics[scale=0.5]{img/gmint1.png}
		\caption{First gm-integrator derived from the equations in \ref{eq:svc1}}
		\label{fig:gmint1}
	\end{center}
\end{figure}\\
The values of the gm's are as follows:
\begin{equation}
	\begin{split}
		gma	& = gmc = - \dfrac {1} {R_1}\\
		gmb	& = \dfrac {1} {R_1}\\
	\end{split}
\end{equation}
For state variable $i_L$:
\begin{equation}
	\begin{split}
		sL = \dfrac {V_L} {i_L}	& \Rightarrow si_L\cdot L = V_L\\
		si_L\cdot L				& = V_{C_1} - V_{C_2}\\
		si_L					& = \dfrac {V_{C_1}} {L} - \dfrac {V_{C_2}} {L}\\
		s\dfrac {V_L} {R_1}		& = \dfrac {V_{C_1}} {L} - \dfrac {V_{C_2}} {L}\\
		sV_L					& = \dfrac {R_1} {L}V_{C_1} - \dfrac {R_1} {L}V_{C_2}\\
	\end{split}
	\label{eq:svl}
\end{equation}
We need resistors and capacitors, no inductors. So we have to make the terms of the form $\dfrac {v} {RC}$:
$\dfrac {R_1} {L} = \dfrac {1} {R_aC_{int}} = \dfrac {1} {R_bC_{int}}$, if we use $R_a=R_b=R_1$ we get: $C_{int} = \dfrac {L} {R_1^2}$.\\
These equations give us the integrator in figure \ref{fig:gmint2}.
\begin{figure}[h]
	\begin{center}
		\includegraphics[scale=0.5]{img/gmint2.png}
		\caption{Second gm-integrator derived from the equations in \ref{eq:svl}}
		\label{fig:gmint2}
	\end{center}
\end{figure}\\
The values of the gm's are as follows:
\begin{equation}
	\begin{split}
		gmd	& = \dfrac {1} {R_1}\\
		gme	& = - \dfrac {1} {R_1}\\
	\end{split}
\end{equation}
For state variable $V_{C_2}$:
\begin{equation}
	\begin{split}
		\dfrac {1} {sC_2} = \dfrac {V_{C_2}} {i_{C_2}}	& \Rightarrow sV_{C_2}\cdot C_2=i_{C_2}\\
		sV_{C_2}\cdot C_2								& = i_L - i_{R_2}\\
%														& = i_L - \dfrac {V_{C_2}} {R_2}\\
														& = \dfrac {V_L} {R_1} - \dfrac {V_{C_2}} {R_2}\\
		sV_{C_2}										& = \dfrac {V_L} {R_1C_2} - \dfrac {V_{C_2}} {R_2C_2}\\
	\end{split}
	\label{svc2}
\end{equation}
These equations give us the integrator in figure \ref{fig:gmint3}.
\begin{figure}[h]
	\begin{center}
		\includegraphics[scale=0.5]{img/gmint3.png}
		\caption{Second gm-integrator derived from the equations in \ref{eq:svc2}}
		\label{fig:gmint3}
	\end{center}
\end{figure}\\
The values of the gm's are as follows:
\begin{equation}
	\begin{split}
		gmg	& = - \dfrac {1} {R_2}\\
		gmf	& = \dfrac {1} {R_1}\\
	\end{split}
\end{equation}

\section{}%9
Putting figures \ref{fig:gmint1} to \ref{fig:gmint3} together we het the integrator in figure \ref{fig:filter_active}. In this figure $V_{C_2}=V_{out}$.
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=0.8\textwidth]{img/filter_active.png}
		\caption{Complete gm-integrator in LTSpice using the values of exercise 6 and the calculations of exercise 8}
		\label{fig:filter_active}
	\end{center}
\end{figure}
\section{}%10
Figure \ref{fig:response_active} shows the same response as figure \ref{fig:response_passive} in exercise 7.
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/response_active.png}
		\caption{The response of the active filter using the values calculated in exercise 6}
		\label{fig:response_active}
	\end{center}
\end{figure}

\section{}%11
Setting the capacitors C1 and C2 to $250fF$, gives us the following values after using the same equations as before. The results are shown in figures \ref{fig:filter_active_11} and \ref{fig:response_active_11}. The response is again the same.
\begin{equation}
	\begin{split}
		R_1			& = 63.662k\Omega\\
		R_2			& = 6.3662M\Omega\\
		L			& = 2mH\\
		C_{int}		& = 500fF\\
		gma			& =	gmb = gme = gmg = -15.708\mu S\\
		gmc			& =	gmd = gmf = 15.708\mu S\\
	\end{split}
	\label{eq:scaled}
\end{equation}
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/filter_active_11.png}
		\caption{The scheme of the active filter using the values calculated in equation \ref{eq:scaled}}
		\label{fig:filter_active_11}
	\end{center}
\end{figure}
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/response_active_11.png}
		\caption{The response of the active filter in figure \ref{fig:filter_active_11}}
		\label{fig:response_active_11}
	\end{center}
\end{figure}
\clearpage
\section{}%12
Figure \ref{fig:response_active_11} shows that 3 of the 7 gm's are positive. Gmc is located at the input and since the signal from the input is AC we can simply change the sign of this gm without affecting the response. This leaves us with gmd and gmf. If we want them to be negative gm's, the input voltages have to be inverted, we will use simple gm inverters at their inputs to make this work. A gm inverter is shown in figure \ref{fig:gm_inverter}. This works because:
\begin{equation}
	\begin{split}
		i			& = -gm\cdot V_{in}\\
		V_{out}		& = R\cdot i = R\cdot -gm\cdot V_{in}\\
					& = -V_{in}\text{, when }R=\dfrac {1} {gm}\\
	\end{split}
	\label{eq:scaled}
\end{equation}
\begin{figure}[h]
	\begin{center}
		\includegraphics{img/gm_inverter.png}
		\caption{A gm inverter}
		\label{fig:gm_inverter}
	\end{center}
\end{figure}
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/filter_active_12.png}
		\caption{The scheme of the active filter using only negative gm's}
		\label{fig:filter_active_12}
	\end{center}
\end{figure}
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/response_active_12.png}
		\caption{The response of the active filter in figure \ref{fig:filter_active_12}}
		\label{fig:response_active_12}
	\end{center}
\end{figure}

\section{}%13
The values are the same as in exercise 6, however in the scheme in figure \ref{fig:RCfilter} they have slightly different names so LTSpice can simulate the filter. We will clarify the names: $R\_1\_*=R_1$, in exercise 8 it was already mentioned that $Ra=Rb=R_1$ and $R\_1\_*=100$, these resistors are used to invert the signal through the opamp. Their actual values are not that important they just have to be equal, that is $R\_1\_1=R\_1\_2$ and $R\_1\_3=R\_1\_4$. The response of this filter is almost equal to the previous ones, the only difference is that the size of the peak at $10MHz$ is a little higher. The difference is caused by the opamps which are not as ideal as we would like them to be.

\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/RCfilter.png}
		\caption{The scheme of the RC filter obtained from the state equations in exercise 8}
		\label{fig:RCfilter}
	\end{center}
\end{figure}
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/RCresponse.png}
		\caption{The response of the RC filter in figure \ref{fig:RCfilter}}
		\label{fig:RCresponse}
	\end{center}
\end{figure}

\section{}%14
Setting the capacitors C1 and C2 to $160fF$, gives us the following values after using the same equations as before.
\begin{equation}
	\begin{split}
		R_1			& = 99.472k\Omega\\
		R_2			& = 9.9472M\Omega\\
		L			& = 3.2mH\\
		C_{int}		& = 320fF\\
	\end{split}
	\label{eq:scaledRC}
\end{equation}
The opamp resistors are independant of the rest so we will just use $80k\Omega$ there.
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/RCfilter_14.png}
		\caption{The scheme of the RC filter using the values calculated in equation \ref{eq:scaledRC}}
		\label{fig:RCfilter_14}
	\end{center}
\end{figure}
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/RCresponse_14.png}
		\caption{The response of the RC filter in figure \ref{fig:RCfilter_14}}
		\label{fig:RCresponse_14}
	\end{center}
\end{figure}
\clearpage
\section{}%15
\begin{figure}[h]
	\begin{center}
		\includegraphics[width=\textwidth]{img/response_passive_15.png}
		\caption{The response of the filter with $R2=1.001R1$.}
		\label{fig:response_passive_15}
	\end{center}
\end{figure}\noindent
In equations A-17 to A-19 in the appendix of the assignment some simplifications are made based on the assumption that $R2 \gg R1$. This assumption no longer holds, which means the denominator of the fraction in A-17 is larger so the output power is lower. This is shown in figure \ref{fig:response_passive_15}.
\section{}%16
-
\end{document}
